package sudroid.android;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.zip.ZipFile;
import sudroid.AssertUtil;
import sudroid.LogUtils;

public class PackageManagerUtil
{
  public static Set<String> getInstalledPackagenameSet(Context paramContext)
    throws IOException
  {
    AssertUtil.checkNull(paramContext);
    HashSet localHashSet = new HashSet();
    List localList = paramContext.getPackageManager().getInstalledApplications(0);
    Iterator localIterator;
    if (localList.size() != 0)
      localIterator = localList.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return localHashSet;
      String str = ((ApplicationInfo)localIterator.next()).packageName;
      boolean bool = localHashSet.add(str);
    }
  }

  public static String getPackageName(Context paramContext, File paramFile)
  {
    AssertUtil.checkNull(paramContext);
    AssertUtil.checkNull(paramFile);
    String str2;
    if (FileUtil.doesExisted(paramFile))
    {
      String str1 = String.valueOf(paramFile.getAbsolutePath());
      LogUtils.w(str1 + " doesn't exist!");
      str2 = null;
    }
    while (true)
    {
      return str2;
      PackageInfo localPackageInfo;
      try
      {
        ZipFile localZipFile = new ZipFile(paramFile, 1);
        PackageManager localPackageManager = paramContext.getPackageManager();
        String str3 = paramFile.getAbsolutePath();
        localPackageInfo = localPackageManager.getPackageArchiveInfo(str3, 0);
        if (localPackageInfo != null)
          break label130;
        LogUtils.w("Can't get package archive info!");
        str2 = null;
      }
      catch (IOException localIOException)
      {
        String str4 = String.valueOf(paramFile.getAbsolutePath());
        LogUtils.w(str4 + " is not a zip file!");
        str2 = null;
      }
      continue;
      label130: str2 = localPackageInfo.packageName;
    }
  }

  public static String getPackageName(Context paramContext, String paramString)
  {
    AssertUtil.checkNull(paramContext);
    AssertUtil.checkStringNullOrEmpty(paramString);
    File localFile = new File(paramString);
    return getPackageName(paramContext, localFile);
  }

  public static String getVersion(Context paramContext)
    throws PackageManager.NameNotFoundException
  {
    PackageManager localPackageManager = paramContext.getPackageManager();
    String str1 = paramContext.getPackageName();
    PackageInfo localPackageInfo = localPackageManager.getPackageInfo(str1, 64);
    if (localPackageInfo == null);
    for (String str2 = null; ; str2 = localPackageInfo.versionName)
      return str2;
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.android.PackageManagerUtil
 * JD-Core Version:    0.6.0
 */